﻿using Castle.DynamicProxy;
using CNKI.TPI.Web.Base;
using CNKI.TPI.Web.Interface.Models;
using CNKI.TPI.Web.Search.IBLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;

namespace CNKI.TPI.Web.Interface.Areas.Category.Controllers
{
    public class DeleteCategoryTypeController : BaseApiController
    { 
        INaviService naviService = null;
        public DeleteCategoryTypeController(INaviService naviService)
        {
            this.naviService = generator.CreateInterfaceProxyWithTarget<INaviService>(naviService, new IInterceptor[] { new LogInterceptor() });
        }

        // POST api/deletecategory
        public object Post()
        {
            OutputEntity result = new OutputEntity();
            try
            {
                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context     
                HttpRequestBase request = context.Request;//定义传统request对象
                string dbcode = request.Form["dbcode"];
                int sysid = int.Parse(request.Form["sysid"]);

                bool m = naviService.DelCLS(sysid, dbcode);
                if (m)
                {
                    result.Status = Status.Success;
                }
                else
                {
                    result.Status = Status.Error;
                }
            }
            catch (Exception ex)
            {
                LogOpr.Error(ex.ToString());
                result.Status = Status.Error;
                result.message = ex.Message;
            }
            return result;
        }

        // DELETE api/deletecategory/5
        /// <summary>
        /// 根据导航分类ID删除对应的导航分类CLS
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dbcode"></param>
        //public object Get(int id,string dbcode)
        //{
        //    OutputEntity result = new OutputEntity();
        //    try
        //    {
        //        bool m=naviService.DelCLS(id, dbcode);
        //        if (m)
        //        {
        //            result.Status = Status.Success;
        //        }
        //        else
        //        {
        //            result.Status = Status.Error;
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        LogOpr.Error(ex.ToString());
        //        result.Status = Status.Error;
        //    }
        //    return result;
        //}
    }
}
